<template>
  <div class="unit-box" id="unit-box-scroll">
    <div class="unit-exbit">
      <div class="unit-exbit-title-box">
        <div class="unit-exbit-title-box-right-box" v-if="store.childModel.value">
          <div class="bgc-shadow" :style="{ background: colorList5[store.styleInfo.colorType - 1].shmentColor }"></div>
          <img
            class="unit-exbit-title-box-right t-image--fit-cover t-image--position-center"
            :src="urls + store.childModel?.value + '?imageView2/1/w/580/h/326/format/webp'"
            alt=""
            v-if="store.childModel?.value"
          />
          <div class="UnitImageNull" v-else>
            <UnitImageNull />
          </div>
        </div>
        <div class="unit-exbit-title-box-left" v-if="store.childModel?.remarks">
          <textMax
            v-if="store.childModel?.remarks"
            :title="store.childModel?.text"
            :color="colorList5[store.styleInfo.colorType - 1].fontColor"
            :data="store.childModel?.remarks"
            :modelData="remarks"
            :maxLen="store.childModel.value ? 7 : 3"
          />
        </div>
      </div>
      <unitChildinfo v-model="typeIndex" />
      <auxiliarys
        :Auxiliaryslist="
          store.childModel.children[typeIndex].auxiliaryList ? store.childModel.children[typeIndex].auxiliaryList : []
        "
        :moduleId="store.childModel.children[typeIndex].id"
        :imgBackground="colorList5[store.styleInfo.colorType - 1].auxiliaryColor"
        :exhibitBackground="colorList5[store.styleInfo.colorType - 1].shmentColor"
        @emitExhibits="emitExhibits"
      />
      <div class="exhibit-list" id="exhibit-list-99id"></div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { useRouter, useRoute } from 'vue-router';
import unitChildinfo from './unitChildinfo.vue';
import paginationPage from '../../components/paginationPage.vue';
import childInfo from './childInfo.vue';
import textMax from '../../components/textMax.vue';
import imageNull from '@/components/imageNull/index.vue';
import { getTextHtml, filterHTML } from '@/utils/minxin';
import { exhibitShowpiece } from '@/api/templates/templates';
import { colorList5 } from '../../../data';
import titles from '../../components/title.vue';
import { urls } from '@/utils/request/upload';
import { ref, reactive, computed, watch, onMounted, nextTick } from 'vue';
import { MessagePlugin } from 'tdesign-vue-next';
import { useProjectStore } from '@/store';
import { moduleShowpieces } from '@/api/exhibit/exhibit';
import { storeToRefs } from 'pinia';
import { pathList, pathListLoop } from '../../index';
import UnitImageNull from '@/components/unitImageNull/unitImageNull.vue';
import auxiliarys from './auxiliarys/index.vue';
const router = useRouter();
const route = useRoute();
const store = useProjectStore();
const { childModel } = storeToRefs(store);
const total = ref(0);
const remarks = ref('');
const typeIndex = ref(0);
const exbitMarsk = ref('');
const loading = ref(false);
const list = ref([]);
const parmas = reactive({
  pageSize: 14,
  pageNo: 1,
  id: 0,
  value: '',
});
remarks.value = getTextHtml(store.childModel?.remarks);

const initList = async () => {};
const pathInfo = (id: number) => {
  router.push({
    name: route.meta.loopType ? pathListLoop[7] : pathList[7],
    query: {
      showpieceid: id,
      moduleId: parmas.id,
    },
  });
  setTimeout(() => {
    const ele = document.getElementById('timeAxis-child-box-id'); // 获取元素
    const top = ele.offsetTop - 140; // 获取元素距离文档顶部的距离
    window.scrollTo({
      top: top,
      //behavior: 'smooth', // 设置滚动的动画效果
    });
  }, 100);
};
const emitExhibits = (moduleId: number, id: number) => {
  router.push({
    name: route.meta.loopType ? pathListLoop[7] : pathList[7],
    query: {
      showpieceid: id,
      moduleId: moduleId,
    },
  });
  setTimeout(() => {
    const ele = document.getElementById('timeAxis-child-box-id'); // 获取元素
    const top = ele.offsetTop - 140; // 获取元素距离文档顶部的距离
    window.scrollTo({
      top: top,
      behavior: 'smooth', // 设置滚动的动画效果
    });
  }, 100);
};

const change = (e: any) => {
  // console.log(e);
  parmas.pageNo = e.page;
  setTimeout(() => {
    // const ele = document.getElementById('exhibit-list-99id'); // 获取元素
    // const top = ele.offsetTop + 980; // 获取元素距离文档顶部的距离
    // window.scrollTo({
    //   top: top,
    //   //behavior: 'smooth', // 设置滚动的动画效果
    // });
  }, 100);
};
watch(
  childModel,
  () => {
    typeIndex.value = 0;
    remarks.value = getTextHtml(store.childModel?.remarks);
  },
  { deep: true },
);
watch(
  typeIndex,
  () => {
    // parmas.id = store.childModel.children[typeIndex.value].id;
  },
  { deep: true },
);
</script>

<style lang="less" scoped>
@import '../../index.less';
.unit-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  // min-width: 1440px;
  padding-bottom: 0;
}
.unit-exbit-title-box {
  display: flex;
  align-items: center;
  width: 1180px;
  margin: 0 auto;
}
.unit-exbit-title-box-left {
  display: flex;
  max-height: 210px;
  flex: 1;
  margin-bottom: 30px;
}
.unit-exbit-title-box-right-box {
  position: relative;
  width: 550px;
  height: 386px;
  margin-right: 50px;
  margin-left: 20px;
  img {
    width: 550px;
  }
}
.bgc-shadow {
  position: absolute;
  top: -20px;
  left: -20px;
  width: 280px;
  height: 186px;
}
.unit-exbit-title-box-right,
.UnitImageNull {
  position: relative;
  z-index: 20;
  width: 580px;
  height: 386px;
}
.unit-exbit-null {
  width: 1180px;
  margin: 0 auto;
  position: relative;
  background: #cbb995;
}
.bgc-box1 {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 20;
  width: 100%;
  height: 100%;
  background: url('https://static.jiyi.show/template/template5/textBgc1.png');
}
.bgc-box2 {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 20;
  width: 100%;
  height: 100%;
  background: url('https://static.jiyi.show/template/template5/textBgc2.png');
}
.bgc-box3 {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 20;
  width: 100%;
  height: 100%;
  background: url('https://static.jiyi.show/template/template5/textBgc3.png');
}
.unit-exbit-null-remarks {
  position: relative;
  z-index: 50;
  width: 100%;
  padding: 50px 80px;
}
.unit-exbit-null-remarks-info {
  display: flex;
  flex-direction: column;
  min-height: 240px;
  max-height: 610px;
  overflow-y: auto;
  span {
    text-indent: 2em;
    font-size: 17px;

    color: #333333;
    line-height: 30px;
  }
}
.exhibits-item-img {
  position: relative;
  z-index: 80;
  width: 1180px;
  height: 400px;
}
//
.unit-exbit-null-remarks {
}
.unit-exbit-null-remarks-info {
  height: 40px;
  scrollbar-thumb {
    height: 40px;
  }
}
.exhibit-list {
  display: flex;
  width: 1180px;
  margin: 0 auto;
  margin-top: 80px;
}
.item-style {
  width: 280px;
}
.t-col {
  margin-bottom: 0px;
}
.t-row {
  margin-top: 0px;
}
.btm-box {
  display: flex;
  align-items: center;
  width: 100%;
  height: 50px;
  span {
    font-size: 18px;
    font-family: SourceHanSerifCN-Medium, SourceHanSerifCN;
    color: #ffffff;
    line-height: 28px;
    color: #fff;
    text-align: center;
    width: 100%;
    white-space: nowrap; /* 不换行 */
    overflow: hidden; /* 溢出隐藏 */
    text-overflow: ellipsis; /* 添加省略号 */
  }
}
.item3-box-child1 {
  display: flex;
  flex-direction: column;
}
.item3-box {
  display: flex;
  width: 1180px;
  margin: 0 auto;
  justify-content: space-between;
}
.item3-box-child1 {
  width: 280px;
  display: flex;
  flex-direction: column;
}
.paginationPage-box {
  width: 100%;
  margin: 80px 0;
  margin-bottom: 160px !important;
}
.unit-exbit {
  width: 100%;
  padding-bottom: 100px;
}
</style>
